home *** CD-ROM | disk | FTP | other *** search
- /*****************************************************************
- CNeoWindow.h
-
- Header file for the CNeoWindow class.
- *****************************************************************/
-
- #ifndef __CNeoWindow__
- #define __CNeoWindow__
-
- #include <Timer.h>
- #include "LWindow.h"
- #include "LPeriodical.h"
- #include "LListener.h"
- #include "NeoBench.h"
-
- class CNeoDatabasePP;
- class CNeoIndexIterator;
- class CRawText;
- class LEditField;
- class LButton;
- class CNeoWindow;
- #ifndef qNeoPersist
- class CNeoIndexIterator;
- #endif
-
- #define kTitlePICTID 129
-
- #ifdef qNeoThreads
- #include CNeoThreadNativeH
-
- typedef enum {
- kDie,
- kAlive
- } health;
-
- #define kMaxThreads 5
-
- typedef struct {
- short phase; /* Phase of work being done */
- health state; /* Healthiness of this thread */
- CNeoWindow * window; /* Window this thread is working for */
- CNeoThreadNative * thread; /* Pointer to thread */
- } ThreadInfo;
-
- class CBenchThread : public CNeoThreadNative
- {
- public:
- CBenchThread(ThreadInfo *aInfo, const NeoThreadType aType = kNeoCoopThread, void **aArg = nil, const Size aStackSize = kNeoDefaultStackSize, const NeoThreadOptions aOptions = (kNeoThreadNewSuspend + kNeoThreadUsePremade + kNeoThreadCreate));
- virtual long run(void);
-
- virtual void handleSwapIn(void);
- virtual void handleSwapOut(void);
-
- protected:
- Boolean fSetTimer;
- TMTask fTimer;
- ThreadInfo * fInfo;
- };
- #endif
-
- class CNeoWindow : public LWindow, public LPeriodical, public LListener {
- public:
- CNeoWindow(const ResIDT aResID, CNeoDocPP *aDocument);
- virtual ~CNeoWindow(void);
-
- /** Drawing **/
- void DrawSelf(void);
-
- /** Statistics **/
- void checkDatabaseState(void);
- void ClearStatPanes(void);
- short getPhase(void) const;
- long getPhaseTarget(const short aPhase) const;
- Boolean getState(void) const;
- void getTargetTotals(void);
- long GetTotalNum(short index);
- void setDocument(CNeoDocPP *aDoc);
- void setPhase(const short aPhase);
- void setState(const Boolean aState);
- void UpdateCol(short aPhase, short aRow, long aValue);
-
- /** Events/Drawing **/
- virtual void ClickInZoom(const EventRecord& inMacEvent, short inZoomDirection);
- virtual void doSomeWork(const short aPhase, TMTask *aTimer);
- virtual Boolean HandleKeyPress(const EventRecord &inKeyEvent);
- #ifdef qNeoThreads
- void killThreads(void);
- #endif
- virtual void ListenToMessage(MessageT aMessage, void *aParam);
- virtual void SpendTime(const EventRecord &inMacEvent);
-
- protected:
- NeoPhase fPhaseInfo[kMaxPhase +1]; // The main phases
- Boolean fState; // Running state
- Boolean fRefresh; // Update stats on screen
- short fPhase; // The current phase
- #ifdef qNeoThreads
- short fThreadCount; // Current number of slave threads
- ThreadInfo fThreadInfo[kMaxThreads]; // Info used by each thread
- #endif
- CNeoIndexIterator * fIterator; // For traversing index of objects
- long col_value[3]; // 3 columns - soFar, PerRecord, Total
- short col_index; // Index into the column
-
- CRawText * NeoRawTexts[kMaxPhase +1][kMaxCol +1]; // the texts displaying the numbers
- LEditField * NeoEditTexts[kMaxPhase +1]; // the TOTALS editable texts
- CRawText * NeoPhaseNames[kMaxPhase +1]; // Phase names
- LButton * NeoStopButton; // Stop button
- LButton * NeoGoButton; // Go button
- CRawText * fSizeStatic; // Object size label
- LEditField * fSizeText; // Object size text
-
- long maxValue[kMaxPhase +1];
- long minValue[kMaxPhase +1];
- };
- #endif